<?php 
class Config 
{
	var $db_name;
	var $db_user;
	var $db_pass;
	var $db_host;
	var $connection;
	
	var $sql;
	var $query;
	var $data;
	
	var $site_name;
	var $site_description;
	
	var $version = "Dwarf CMS Beta";
	
	function Config($db_host, $db_user, $db_pass, $db_name, $site_name, $site_description)
	{
		$this->db_host = $db_host;
		$this->db_user = $db_user;
		$this->db_pass = $db_pass;
		$this->db_name = $db_name;
		$this->site_name = $site_name;
		$this->site_description = $site_description;
	}
	
	function connect() 
	{
		$this->connection = mysqli_connect($this->db_host, $this->db_user, $this->db_pass, $this->db_name) or die(mysqli_error($this->connection));
	}
	
	function showblog()
	{
		$this->sql = "SELECT * FROM `blog` order by `id` desc";
		$this->query = mysqli_query($this->connection, $this->sql) or die(mysqli_error($this->connection));
		$old = 0;
		$new = $old+1;
		if (mysqli_num_rows($this->query) != 0)
		{
			while ($this->data = mysqli_fetch_array($this->query))
			{
				echo "\n<h1>".$this->data['title']."</h1>\n<p>".$this->data['content']."</p>\nTags: ".$this->data['tags'];
				$old++;
				$new = $old+1;
				if ($old != 0) { echo "\n<hr>\n"; }
			}
		} else 
			{
				echo "No blog posts yet";
			}
	}
	
	function menu() 
	{
		echo "<div id=\"menu\">Menu</div>";
	}
	
	function destruct()
	{
		unset($this);
	}
	function bye() 
	{
		$this->destruct();
		mysqli_close($this->connection);
		echo "\n<!-- exit! -->\n";
	}
	
	function getvar($var)
	{
		return $this->$var;
	}
}
